import { getAction, postAction, putAction, deleteAction } from '@/api/manage'

// 采购单管理
const purchaseList = (params) => getAction('/wms/purchase/list', params)
const purchaseDetail = (id) => getAction('/wms/purchase/queryById', { id })
const purchaseDetailList = (params) => getAction('/wms/purchase/detail/list', params)
const purchaseAdd = (params) => postAction('/wms/purchase/add', params)
const purchaseEdit = (params) => postAction('/wms/purchase/edit', params)
const purchaseDelete = (id) => deleteAction('/wms/purchase/delete', { id })
const purchaseBatchDelete = (ids) => deleteAction('/wms/purchase/deleteBatch', { ids })
const purchaseSubmit = (id) => postAction('/wms/purchase/submit', { id })
const purchaseApprove = (params) => postAction('/wms/purchase/approve', params)
const purchaseCancel = (id) => postAction('/wms/purchase/cancel', { id })
const purchaseExport = (params) => getAction('/wms/purchase/exportXls', params)

// 物料预警管理
const warningList = (params) => getAction('/wms/purchase/warning/list', params)
const warningRefresh = () => postAction('/wms/purchase/warning/refresh')
const warningMarkHandled = (id) => postAction('/wms/purchase/warning/markHandled', { id })
const warningGeneratePurchase = (params) => postAction('/wms/purchase/warning/generatePurchase', params)
const warningExport = (params) => getAction('/wms/purchase/warning/exportXls', params)

// 自动采购
const autoGeneratePurchase = () => postAction('/wms/purchase/auto/generate')
const getAutoConfig = () => getAction('/wms/purchase/auto/config')
const updateAutoConfig = (params) => putAction('/wms/purchase/auto/config', params)

// 采购入库
const createInboundFromPurchase = (params) => postAction('/wms/purchase/inbound/create', params)
const getPurchaseInboundRelation = (purchaseId) => getAction('/wms/purchase/inbound/relation', { purchaseId })

// 采购质检
const getQualifiedUnprocessedInspection = (purchaseOrderNo) => getAction('/wms/purchase/inspection/getQualifiedUnprocessed', { purchaseOrderNo })
const updateInspectionStatus = (ids) => postAction('/wms/purchase/inspection/updateStatus', { ids })

// 采购到货历史
const getArrivalHistory = (purchaseOrderId) => getAction('/wms/purchase/arrival/history', { purchaseOrderId })
const getMaterialArrivalQuantity = (purchaseOrderId) => getAction('/wms/purchase/arrival/materialQuantity', { purchaseOrderId })

export {
  // 采购单管理
  purchaseList,
  purchaseDetail,
  purchaseDetailList,
  purchaseAdd,
  purchaseEdit,
  purchaseDelete,
  purchaseBatchDelete,
  purchaseSubmit,
  purchaseApprove,
  purchaseCancel,
  purchaseExport,
  
  // 物料预警管理
  warningList,
  warningRefresh,
  warningMarkHandled,
  warningGeneratePurchase,
  warningExport,
  
  // 自动采购
  autoGeneratePurchase,
  getAutoConfig,
  updateAutoConfig,
  
  // 采购入库
  createInboundFromPurchase,
  getPurchaseInboundRelation,
  
  // 采购质检
  getQualifiedUnprocessedInspection,
  updateInspectionStatus,
  
  // 采购到货历史
  getArrivalHistory,
  getMaterialArrivalQuantity
} 